var app = getApp();
var Utils = require('../../../../utils/util.js');
Page({
  data: {
    // 请求数据是否有值（添加或被添加）
    currentTab: 0,
    setinterval: '',
    have_data: false,
    current: null,
    currentFriend: null,
    start: null,
    setintervalFunction: '',
    end: null,
    startFriend: null,
    endFriend: null,
    list: [],
    haoyou_list: [],
    currentResultOne: 0,
    currentResultTwo: 0,
    loadingBoo: !0,
    moreBooOne: !0,
    moreBooTwo: !0,
    // 我的患者咨询列表
    // 我的患者咨询列表已完成的消息
    resultListTwo: [{
      orderId: 1,
      doctorId: 1,
      patientSimpleVo: {
        userId: 1,
        userIcon: '/assets/images/head.png',
        name: '小强',
        nmGender: '男',
        age: 30
      },
      medType: 1,
      msgTxt: '哈哈',
      sessionDateBegin: '2018-10-22-14:19',
      // 完成与否
      status: '1',
      // 消息
      nonReadCount: '0'
    }],
    explanBooOne: !1,
    explanBooTwo: !1,
    current: 1,
    // 团队患者咨询
    TeamList: [{
        teamId: 1,
        teamName: '血液',
        teamHeaderUrl: '/assets/images/head.png',
        doctorNurseCount: 3,
        patientCount: 10,
        nonReadTipCount: 3
      },
      {
        teamId: 1,
        teamName: '骨科',
        teamHeaderUrl: '/assets/images/head.png',
        doctorNurseCount: 3,
        patientCount: 10,
        nonReadTipCount: 0
      }
    ],
    nonReadBoo: !0,
    nonReadBoo1: !0,
    if_over: 0,
    _num: 0
  },
  tiaozhuan1(e) {
    var that = this
    console.log(e)
    var list = e.currentTarget.dataset
    var useropenid = e.currentTarget.dataset.useropenid
    var orders = e.currentTarget.dataset.orders
    wx.setStorage({
      key: 'userinfotype',
      data: 'user',
    })
    var u_thumb = e.currentTarget.dataset.u_thumb
    wx.setStorage({
      key: 'u_thumb',
      data: u_thumb,
    })
    let userInfo = wx.getStorageSync('userInfo')
    let bl_id = e.currentTarget.dataset.bl_id
    wx.setStorage({
      key: 'userInfo',
      data: userInfo,
    })
    let z_thumbs = e.currentTarget.dataset.z_thumbs //医生头像
    wx.setStorage({
      key: 'z_thumbs',
      data: z_thumbs,
    })
    let sate = 1
    wx.setStorageSync('sate', sate) //证明是医生发送的信息
    var my = e.currentTarget.dataset.docroom; //医生自己
    var your = e.currentTarget.dataset.myroom; //患者
    wx.setStorageSync('docroom', your)
    var nameList = {
      myName: my,
      your: your,
      bl_id: bl_id
    };
    wx.navigateTo({
      url: '/hyb_yl/czhuanjiasubpages/pages/chatroom/chatroom?username=' + JSON.stringify(nameList) + '&list=' + JSON.stringify(list) + '&z_name=' + e.currentTarget.dataset.z_name + '&useropenid=' + useropenid + '&orders=' + orders
    })
  },
  tiaozhuan2(e) {
    clearInterval(this.data.setinterval);
    wx.navigateTo({
      url: `/hyb_yl/backstageFollowUp/pages/explanationComplete/explanationComplete?sessionId=${e.currentTarget.dataset.orderId}&doctorId=${e.currentTarget.dataset.doctorId}&userId=${e.currentTarget.dataset.patientSimpleVo.userId}&signType=${e.currentTarget.dataset.medType}`,
    })
  },
  tiaozhuan3(e) {
    clearInterval(this.data.setinterval);
    wx.navigateTo({
      url: `/hyb_yl/backstageFollowUp/pages/consultingTeam/consultingTeam?teamId=${e.currentTarget.dataset.teamId}&teamName=${e.currentTarget.dataset.teamName}`,
    })
  },
  clickNum: function(t) {
    var that = this
    var if_over = t.currentTarget.dataset.num
    that.setData({
      if_over: if_over
    })
    that.setData({
      explanBooOne: !1,
      explanBooTwo: !1,
      moreBooOne: !0,
      moreBooTwo: !0,
      currentResultOne: 0,
      currentResultTwo: 0,
      _num: if_over
    });
    that.getChatList()
  },
  changeTitle: function(t) {
    var a = this;
    this.setData({
      current: t.target.dataset.current
    })
    this.setData({
      explanBooOne: !1,
      explanBooTwo: !1,
      moreBooOne: !0,
      moreBooTwo: !0,
      currentResultOne: 0,
      currentResultTwo: 0
    })
  },
  reply: function(t) {
    wx.navigateTo({
      url: "/hyb_yl/backstageFollowUp/pages/explanationReply/explanationReply"
    });
  },
  onLoad: function(options) {
    var that = this;
    if (options.index != undefined) {
      var footer = that.data.footer;
      footer.footdex = options.index;
      that.setData({
        footer: footer
      })
    }
    that.getChatList();
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    // //循环查询对方发送的消息 把最新的消息显示出来 计时器6秒执行一次
    // var setintervalFunction = setInterval(function () {
    //   that.getChatList();
    //   wx.hideNavigationBarLoading()
    // }, 6000) //6秒查询一次
    // that.setData({
    //   setinterval: setintervalFunction
    // })
  },
  onShow: function() {

  },
  getMore: function() {
    var t = this;
    t.getPatient(t);
  },

  //获得好友列表移机提醒消息
  getChatList: function() {
    var that = this;
    var if_over = that.data.if_over
    app.util.request({
      'url': 'entry/wxapp/doctuwenlist.haoyoulistwei',
      'data': {
        openid: wx.getStorageSync('openid'),
        if_over: if_over
      },
      success: function(res) {
        console.log(res)
        var info = res.data
        that.setData({
          resultListOne: info
        })
      },
    })
  },
  onUnload: function() {
    clearInterval(this.data.setinterval)
  },
});